﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Url-Shortener-Settings.aspx.cs" Inherits="TSB.SharePointUrlShortener.Layouts.TSB.SharePointUrlShortener.Url_Shortener_Settings" DynamicMasterPageFile="~masterurl/default.master" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <link rel="stylesheet" type="text/css" href="/_layouts/TSB.SharePointUrlShortener/shorturl.css" />
</asp:Content>

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <asp:PlaceHolder ID="phCreate" runat="server">
        <p>Please provide the shortcode, or alternatively use the auto-generated one.</p>
        <asp:Literal ID="ltErrors" runat="server" /> 
        <ul class="shortener">
            <li><asp:Label Text="Short Url" AssociatedControlID="txtShortcode" runat="server"/> <asp:Literal ID="ltSiteUrl" runat="server" /><asp:TextBox runat="server" ID="txtShortcode" CssClass="shortCode" MaxLength="20" /></li>
            <li><label>This will point to the <asp:Literal ID="ltType" runat="server" /></label><br /> <asp:Literal ID="ltUrl" runat="server" /></li>            
         </ul>
        <div id="msgbox" class="msgbox"></div>
        <p><asp:Button ID="btnCreate" runat="server" Text="Create" CssClass="createbtn"/></p>
        
        <script type="text/javascript" src="/_layouts/TSB.SharePointUrlShortener/jquery-1.7.1.min.js"></script>
        <script type="text/javascript">
            $('.shortCode').blur(function () {
                $.getJSON('/_layouts/TSB.SharePointUrlShortener/service.ashx?shortcode=' + $('.shortCode').val(),
                function (data) {
                    if (data.DoesExist) {
                        $('#msgbox').removeClass('good').addClass('bad').html('This shortened Url is already being used for ' + data.ExistingValue);                        
                    }
                    else {
                        $('#msgbox').removeClass('bad').addClass('good').html('This shortened Url is valid');
                    }
                });
            });
        </script>
    </asp:PlaceHolder>

    <asp:PlaceHolder ID="phSuccess" runat="server" Visible="false">
        <p><asp:Literal ID="ltSuccessMessage" runat="server" /></p>
    </asp:PlaceHolder>

    <asp:PlaceHolder ID="phExisting" runat="server" Visible="false">
        <p>A short url already exists, you can access this from:</p>
        <p><asp:Literal ID="ltExisting" runat="server" /></p>

        <Sharepoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl1" runat="server" PermissionsString="DeleteListItems">
            <p>You can use this to delete this shortened Url.</p>
            <asp:Button ID="btnDelete" runat="server" Text="Delete" />
        </Sharepoint:SPSecurityTrimmedControl>
    </asp:PlaceHolder>
</asp:Content>

<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
Short Urls
</asp:Content>

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
Short Urls
</asp:Content>
